#include <iostream>
#include <memory>
#include "Dict.hpp"
#include "UdpServer.hpp"

std::string defaultfunc(const std::string& str)
{
    std::string res = "hello ";
    res += str;
    return res;
}

// 翻译系统: 英文单词翻译为中文

int main(int argc, char* argv[])
{
    if(argc != 2)
    {
        std::cerr << "Usage:" << argv[0] << " port" << std::endl;
        exit(1);
    }
    
    uint16_t port = std::stoi(argv[1]);

    // 字典对象
    Dict dict;
    dict.LoadDict();

    // 网络通信对象
    Enable_Console_Log_Strategy();
    std::unique_ptr<UdpServer> usvr = std::make_unique<UdpServer>(port, [&dict](const std::string& word, InetAddr& client){
        return dict.Translate(word, client);
    });
    usvr->Init();
    usvr->Start();
    return 0;
}